<?php
/**
* Class Connection into Bo Controller
* @author SillySmart
* @copyright SillySmart
* @package Mvc.Controllers.Bo
* @see Mvc.Controllers.Bo.ControllerProtected
* @see Mvc.Controllers.SiteProtected
* @see Sls.Controllers.Core.SLS_GenericController
* @since 1.0
*
*/
class BoConnection extends BoControllerProtected
{
	public function init()
	{
		parent::init();
	}

	public function action()
	{
		$xml = $this->getXML();
		$boActions = SLS_BoRights::getDistinctActions();
		$xml->startTag("bo_actions");
		for($i=0 ; $i<$count=count($boActions) ; $i++)
		{
			$xml->startTag("bo_action");
			foreach($boActions[$i] as $key => $value)
				$xml->addFullTag($key,$value,true);
			$xml->endTag("bo_action");
		}
		$xml->endTag("bo_actions");
		if ($this->_http->getParam("reload") == "true")
		{
			$login 	 = $this->_http->getParam("login");
			$password = $this->_http->getParam("password");
			if (!SLS_BoRights::connect($login,$password))
			{
				$xml->startTag("errors");
				$xml->addFullTag("error","Access denied",true);
				$xml->endTag("errors");
			}
		}
		if (SLS_BoRights::isLogged())
		{
			$xml->addFullTag("isLogged","true",true);
			if (count($boActions) > 1)
				$this->_generic->redirect($boActions[0]["url"]);
		}		$this->saveXML($xml);
	}
}
?>